import json
class Car:
    def __init__(self, img, brand,points):
        self.img = img
        self.brand = brand
        self.points = points

    def __str__(self):
        return f"汽车图片:{self.img},汽车品牌:{self.brand},车牌号位置:{self.points}"

def read_message():
    car_list = []
    with open("label_train.txt","r",encoding="utf-8") as f:
        for line in f:
            line_new = line.strip().split(" ",1)
            #拿到照片信息
            img = line_new[0]

            # 获得品牌信息
            message = line_new[1]
            message_new = json.loads(message)
            message_brand = message_new[0]["brand"]
            # print(message_brand)

            #获得车牌号位置
            message_points = message_new[0]["points"]
            car = Car(img,message_brand,message_points)
            car_list.append(car)
        f.close()
    return car_list

for car in read_message():
    print(car)
